<?php
class Application_Model_DbTable_Celibataire extends Application_Model_DbTable_Mongo{
	
	private $_collection;
	
	public function __construct(){
		parent::__construct();
		//init collection
		$this->_collection= $this->_db->celibataire;
	}
	
	function getCollection(){
		return $this->_collection;
	}
	
	public function insert($data){
		//var_dump($this->_collection);
		$this->_collection->insert($data);
	
	}
	
	public function getByEmail($email){
		$m = new Mongo();

		$cursor = $this->_collection->find();
		//echo $cursor->count();

		//var_dump(iterator_to_array($cursor));
      return $cursor;
	}
	
    public function findById( $filtre=array('_id'=> NULL)){
            $cursor = $this->_Collection->findOne($filtre);
      }

      public function incrementPoint($filtre=array('_id'=> NULL), $point=0){
            $this->_Collection->update($filtre, array('$inc' => array("point" => $point) ));
      }

      public function razVisite($filtre=array('_id'=> NULL)){
            $this->_Collection->update($filtre, array('$set' => array("nouvelle_visites" => 0)));
      }

      public function nouvelleVisite($filtre=array('_id'=> NULL)){
            $this->_Collection->update($filtre, array('$inc' => array("nouvelle_visites" => 1) ));
      }

      public function razMail($filtre=array('_id'=> NULL)){
            $this->_Collection->update($filtre, array('$set' => array("nouveaux_mail" => 0)));
      }

      public function nouveauMail($filtre=array('_id'=> NULL)){
            $this->_Collection->update($filtre, array('$inc' => array("nouveaux_mail" => 1) ));
      }

      public function razCharme($filtre=array('_id'=> NULL)){
            $this->_Collection->update($filtre, array('$set' => array("nouveaux_charme" => 0)));
      }

      public function nouveauCharme($filtre=array('_id'=> NULL)){
            $this->_Collection->update($filtre, array('$inc' => array("nouveaux_charme" => 1) ));
      }
	
	
}